<!--
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-03 14:41:20
 * @LastEditTime: 2023-10-09 16:02:46
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @Description:   :gridOps="gridOptions" other
-->
<template>
  <sc-VxeTable ref="xGrid" :gridEvts="gridEvents" :tablecode="'pro_outsourcing_plan'"
    :url="api.pro.outsourcing.plan.list">
  </sc-VxeTable>

  <SaveDialog v-if="dialog.save" ref="saveDialog" @success="handleSuccess" @closed="dialog.save = false"></SaveDialog>
  <ReciveDialog v-if="dialog.recive" ref="reciveDialog" @success="handleSuccess" @closed="dialog.recive = false">
  </ReciveDialog>
</template>
<script>
export default {
  name: "pro_outsourcing_plan",
};
</script>
<script setup>
import { ref, nextTick } from "vue";

import SaveDialog from "./save";
import ReciveDialog from "./../product";
import api from "@/api";
const dialog = ref({
  save: false,
  recive: false
});

const xGrid = ref({});
const saveDialog = ref({});
const reciveDialog = ref({});

const handleSuccess = () => {
  xGrid.value.refresh();
};
const openRevive = (row) => {
  dialog.value.recive = true;
  nextTick(() => {
    reciveDialog.value.setData(row);
    reciveDialog.value.open("edit");
  });
}
//表格事件
const gridEvents = {
  cellDblclick: function ({ row }) {
    openRevive(row);
  },
  recive: function ({ button }) {
    openRevive(button.selectRecords[0]);
  },
  add: function () {
    dialog.value.save = true;
    nextTick(() => {
      saveDialog.value.open();
    });
  },
  edit: function ({ button }) {
    dialog.value.save = true;
    nextTick(() => {
      saveDialog.value.setData(button.selectRecords[0]);
      saveDialog.value.open("edit");
    });
  },
};
</script>
